package o;

import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;

public final class ane {
    private int ˊ;
    public byte[] ˎ;
    private int ˏ;
    private int ॱ;

    public ane() {
        this.ˎ = anr.ʽ;
    }

    public ane(byte[] bArr) {
        this(bArr, bArr.length);
    }

    public ane(byte[] bArr, int i) {
        this.ˎ = bArr;
        this.ˏ = i;
    }

    public void ˏ(byte[] bArr) {
        ˋ(bArr, bArr.length);
    }

    public void ˊ(anc o_anc) {
        ˋ(o_anc.ˏ, o_anc.ॱ());
        ˋ(o_anc.ˋ() * 8);
    }

    public void ˋ(byte[] bArr, int i) {
        this.ˎ = bArr;
        this.ˊ = 0;
        this.ॱ = 0;
        this.ˏ = i;
    }

    public int ˏ() {
        return ((this.ˏ - this.ˊ) * 8) - this.ॱ;
    }

    public int ॱ() {
        return (this.ˊ * 8) + this.ॱ;
    }

    public int ˎ() {
        amm.ˏ(this.ॱ == 0);
        return this.ˊ;
    }

    public void ˋ(int i) {
        this.ˊ = i / 8;
        this.ॱ = i - (this.ˊ * 8);
        ʼ();
    }

    public void ˋ() {
        int i = this.ॱ + 1;
        this.ॱ = i;
        if (i == 8) {
            this.ॱ = 0;
            this.ˊ++;
        }
        ʼ();
    }

    public void ˎ(int i) {
        int i2 = i / 8;
        this.ˊ += i2;
        this.ॱ = (i - (i2 * 8)) + this.ॱ;
        if (this.ॱ > 7) {
            this.ˊ++;
            this.ॱ -= 8;
        }
        ʼ();
    }

    public boolean ˊ() {
        boolean z = (this.ˎ[this.ˊ] & (DnsConfig.MAX_CACHE_ENTRIES >> this.ॱ)) != 0;
        ˋ();
        return z;
    }

    public int ॱ(int i) {
        if (i == 0) {
            return 0;
        }
        this.ॱ += i;
        int i2 = 0;
        while (this.ॱ > 8) {
            this.ॱ -= 8;
            byte[] bArr = this.ˎ;
            int i3 = this.ˊ;
            this.ˊ = i3 + 1;
            i2 |= (bArr[i3] & 255) << this.ॱ;
        }
        i2 = (i2 | ((this.ˎ[this.ˊ] & 255) >> (8 - this.ॱ))) & (-1 >>> (32 - i));
        if (this.ॱ == 8) {
            this.ॱ = 0;
            this.ˊ++;
        }
        ʼ();
        return i2;
    }

    public void ˋ(byte[] bArr, int i, int i2) {
        int i3 = (i2 >> 3) + i;
        while (i < i3) {
            byte[] bArr2 = this.ˎ;
            int i4 = this.ˊ;
            this.ˊ = i4 + 1;
            bArr[i] = (byte) (bArr2[i4] << this.ॱ);
            bArr[i] = (byte) (bArr[i] | ((this.ˎ[this.ˊ] & 255) >> (8 - this.ॱ)));
            i++;
        }
        int i5 = i2 & 7;
        if (i5 != 0) {
            bArr[i3] = (byte) (bArr[i3] & (255 >> i5));
            if (this.ॱ + i5 > 8) {
                byte b = bArr[i3];
                byte[] bArr3 = this.ˎ;
                int i6 = this.ˊ;
                this.ˊ = i6 + 1;
                bArr[i3] = (byte) (b | ((bArr3[i6] & 255) << this.ॱ));
                this.ॱ -= 8;
            }
            this.ॱ += i5;
            bArr[i3] = (byte) (((byte) (((this.ˎ[this.ˊ] & 255) >> (8 - this.ॱ)) << (8 - i5))) | bArr[i3]);
            if (this.ॱ == 8) {
                this.ॱ = 0;
                this.ˊ++;
            }
            ʼ();
        }
    }

    public void ʻ() {
        if (this.ॱ != 0) {
            this.ॱ = 0;
            this.ˊ++;
            ʼ();
        }
    }

    public void ˏ(byte[] bArr, int i, int i2) {
        amm.ˏ(this.ॱ == 0);
        System.arraycopy(this.ˎ, this.ˊ, bArr, i, i2);
        this.ˊ += i2;
        ʼ();
    }

    public void ˏ(int i) {
        amm.ˏ(this.ॱ == 0);
        this.ˊ += i;
        ʼ();
    }

    public void ॱ(int i, int i2) {
        if (i2 < 32) {
            i &= (1 << i2) - 1;
        }
        int min = Math.min(8 - this.ॱ, i2);
        int i3 = (8 - this.ॱ) - min;
        this.ˎ[this.ˊ] = (byte) (((65280 >> this.ॱ) | ((1 << i3) - 1)) & this.ˎ[this.ˊ]);
        this.ˎ[this.ˊ] = (byte) (((i >>> (i2 - min)) << i3) | this.ˎ[this.ˊ]);
        i3 = i2 - min;
        min = this.ˊ + 1;
        int i4 = i3;
        while (i4 > 8) {
            i3 = min + 1;
            this.ˎ[min] = (byte) (i >>> (i4 - 8));
            i4 -= 8;
            min = i3;
        }
        i3 = 8 - i4;
        this.ˎ[min] = (byte) (this.ˎ[min] & ((1 << i3) - 1));
        this.ˎ[min] = (byte) (((((1 << i4) - 1) & i) << i3) | this.ˎ[min]);
        ˎ(i2);
        ʼ();
    }

    private void ʼ() {
        boolean z = this.ˊ >= 0 && (this.ˊ < this.ˏ || (this.ˊ == this.ˏ && this.ॱ == 0));
        amm.ˏ(z);
    }
}
